package com.atguigu.controller;

import com.atguigu.entity.User;
import com.atguigu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/{userId}/articles")
    public User getArticleList(@PathVariable Integer userId){
        User user = userService.getUserArticle(userId);
        return user;

    }


    @GetMapping("/{userId}")
    public User getUser(@PathVariable Integer userId){
        User user = userService.getById(userId);
        return user;

    }
}
